﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TumbaloSoft.Models;
using IBatisNet.DataMapper;
using System.Collections;
using TumbaloSoft.Helpers.QueryObjects;

namespace TumbaloSoft.Helpers
{
    public class HelperAreaComun
    {
        public static int insert(TumbaloSoft.Models.AreaComun areaComun)
        {
            Mapper.Instance().Insert("AreaComunInsert", areaComun);
            return 0;
        }
        public static void update(TumbaloSoft.Models.AreaComun areaComun)
        {
            Mapper.Instance().Update("AreaComunUpdate", areaComun);
        }
        public static void delete(TumbaloSoft.Models.AreaComun areaComun)
        {
            Mapper.Instance().Update("AreaComunDelete", areaComun);
        }
        public static AreaComun selectById(int id)
        {
            IList areas = Mapper.Instance().QueryForList("AreaComunSelectById", id);
            if (areas.Count == 0) return null;
            AreaComun area = (AreaComun)(areas[0]);
            return area;
        }
        public static IList selectByIdEdificio(int id)
        {
            IList areas = Mapper.Instance().QueryForList("AreaComunSelectByIdEdificio", id);
            return areas;
        }
        public static IList selectAll()
        {
            return Mapper.Instance().QueryForList("AreaComunSelectAll", null);
        }
        public static int selectMaxCodigo()
        {
            return (int)Mapper.Instance().QueryForObject("AreaComunSelectMaxCodigo", null);
        }
        public static int selectCountActivos()
        {
            return (int)Mapper.Instance().QueryForObject("AreaComunSelectCountActivos",null);
        }
        public static List<AreaComun> selectByListaEdificios(List<int> edificios)
        {
            Lista li = new Lista();
            li.lista = edificios;
            IList lista = Mapper.Instance().QueryForList("AreaComunSelectByEdificios",li);
            return new List<AreaComun>(lista.Cast<AreaComun>());
        }
    }
}